package main

import (
	"gopkg.in/yaml.v2"
	"io/ioutil"
	"path/filepath"
)

func NewConfig(configFileName string) (*Config, error) {
	configFileDir := filepath.Dir(configFileName)
	configFilePath := filepath.Join(configFileDir, configFileName)

	yamlFile, err := ioutil.ReadFile(configFilePath)
	if err != nil {
		return nil, err
	}
	conf := new(Config)
	err = yaml.Unmarshal(yamlFile, conf)
	if err != nil {
		return nil, err
	}
	return conf, nil
}
